﻿Imports System.Data
Partial Class CtrlUsr_Ctrl_AcepOferta
    Inherits CtrlUsrComun

    Public Event GuardarClicked As EventHandler
    Public Event CancelClicked As EventHandler
    Public Property Id_Oferta() As String
        Get
            Return ViewState("Id_Oferta")
        End Get
        Set(ByVal value As String)
            ViewState("Id_Oferta") = value
        End Set
    End Property
    Public Property Estado() As String
        Get
            Return ViewState("Estado")
        End Get
        Set(ByVal value As String)
            ViewState("Estado") = value
        End Set
    End Property
    Public Property Mensaje() As String
        Set(ByVal value As String)
            ViewState("Mensaje") = value
        End Set
        Get
            Return ViewState("Mensaje")
        End Get
    End Property
    Public Property LErroG() As Boolean
        Set(ByVal value As Boolean)
            ViewState("LErroG") = value
        End Set
        Get
            Return ViewState("LErroG")
        End Get
    End Property
    Protected Overridable Sub Onclick(ByVal sender As Object)
        Select Case Me.Oper
            Case "Guardar"
                RaiseEvent GuardarClicked(sender, New EventArgs)
            Case "Cancelar"
                RaiseEvent CancelClicked(sender, New EventArgs)
        End Select
    End Sub
    Public Sub Limpiar()
        Me.TxtCargo.Text = ""
        Me.TxtFecI.Text = Today
        Me.TxtFecF.Text = Today.AddMonths(6)
        Me.LbEst.Text = Me.Estado
    End Sub

    Protected Sub BtnAceptar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnAceptar.Click
        Me.Oper = "Guardar"
        Dim obj As New Ofertas
        Me.Mensaje = obj.Aceptar(TxtFecI.Text, TxtFecF.Text, TxtCargo.Text, Me.Id_Oferta)
        Me.LErroG = obj.lErrorG
        Onclick(sender)
    End Sub

    Protected Sub Button5_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button5.Click
        Me.Oper = "Cancelar"
        Onclick(sender)
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Me.CompareValidator1.ValueToCompare = Today
        Me.CompareValidator2.ValueToCompare = Today
    End Sub

    Protected Sub TxtFecI_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TxtFecI.TextChanged
        Me.TxtFecF.Text = CDate(TxtFecI.Text).AddMonths(6)
    End Sub
End Class